﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace DataLayer.Model.Objects
{
    [DataContract]
    public class Macro 
    {
        private List<Action> _macroList;

        [DataMember]
        public string Name;

        [DataMember]
        public List<Action> Actions { get { return _macroList; } set { _macroList = value; } }



        public void DoWork()
        {
            if(_macroList!=null && _macroList.Count>0)
            foreach (var action in _macroList)
                action.DoAction();
        }
    
        public void Add(Action pAction)
        {
            if (_macroList == null)
                _macroList = new List<Action>();
            _macroList.Add(pAction);
        }

        public void Insert(Action pAction,int pPosition)
        {
            if (pPosition > _macroList.Count)
            {
                _macroList.Insert(pPosition,pAction);
            }
            else
            {
                Add(pAction);
            }
        }
    }
}
